<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_latest
 *
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
?>

<div class="container ultimas-noticias">
	<h3>Últimas Notícias</h3>
	<ul>
		<?php 
		$i = 0;
		$tot = count($list);
		
		foreach ($list as $item) :  
			$images = json_decode($item->images);		
			$dia = substr($item->publish_up, 8, 2) ;
			$mes = substr($item->publish_up, 5, 2) ;
			?>
			
				<?php if (isset($images->image_intro) && !empty($images->image_intro) && $i<4) : ?>
				<li <?php echo 'class="comfoto '; if($i % 2==0): echo ' par '; endif; echo '"';?> >					
					
						<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
						<div class="item-image"> 
							<img alt="<?php echo $images->image_intro_caption ?>" align="middle" <?php if ($images->image_intro_caption): echo ' title="' .htmlspecialchars($images->image_intro_caption) .'"';endif; ?>
							src="<?php echo htmlspecialchars($images->image_intro); ?>"  /> 
							<?php if(!empty($images->image_intro_caption)):?>
				<span class="legend"><?php echo htmlspecialchars($images->image_intro_caption); ?></span>
				<?php endif;?>
						</div>												
						<div class="conteudo">
							<h4><?php echo htmlspecialchars($images->image_intro_alt) ?></h4>										
							<a href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
							<p><?php echo $item->introtext; ?> </p>
						</div>							
				</li>	
			
			<?php else : ?>
				<li	<?php echo 'class="semfoto '; 
				if ($tot % 2 ==0 && $i>=$tot-2) 
					echo 'ultimo';
				elseif($i==($tot-1))
					echo 'ultimo'; 
				  
				echo '"';?>
				>		
					<div><h4><?php echo htmlspecialchars($images->image_intro_alt) ?></h4>			
					<a href="<?php echo $item->link; ?>" title="<?php echo $item->title; ?>"><?php echo $dia.'/'.$mes.' - '. $item->title; ?></a>
					<p><?php echo $item->introtext; ?> </p>
					</div>
				</li>
		<?php endif; ?>				
				
	<?php $i++; 
	
	
	endforeach; ?>
	</ul>
	
	
</div>


